import { combineReducers, createStore } from "redux";

const initialState = {
  curSumId: 0,
  searchSumId: 0,
};

const sumSlice = (
  state = initialState,
  action: { type: string; payload: number },
) => {
  switch (action.type) {
    case "CLEAN_SEARCH_SUM_ID":
      return {
        ...state,
        searchSumId: 0,
      };
    case "SET_SEARCH_SUM_ID":
      return {
        ...state,
        searchSumId: action.payload,
      };
    default:
      return state;
  }
};
const reducer = combineReducers({
  summer: sumSlice,
});
export const store = createStore(reducer);
